USE [Genesis]
GO

/****** Object:  Table [dbo].[Exception_LogEntry]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Exception_LogEntry](
	[LogEntryGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[LogEntryTypeId] [int] NOT NULL,
	[LogEntryXml] [xml] NOT NULL,
	[ProcessDateTime] [datetime] NOT NULL,
 CONSTRAINT [PK_Exception_LogEntry] PRIMARY KEY CLUSTERED 
(
	[LogEntryGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Lookup_BarItemType]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Lookup_BarItemType](
	[BarItemTypeId] [int] IDENTITY(0,1) NOT NULL,
	[BarItemTypeName] [nvarchar](30) NOT NULL,
 CONSTRAINT [PK_Lookup_BarItemType] PRIMARY KEY CLUSTERED 
(
	[BarItemTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Lookup_FileType]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Lookup_FileType](
	[FileTypeId] [int] IDENTITY(0,1) NOT NULL,
	[FileTypeName] [nvarchar](30) NOT NULL,
	[FileTypeDescription] [ntext] NULL,
	[FileTypeExtension] [nvarchar](50) NULL,
 CONSTRAINT [PK_Lookup_FileType] PRIMARY KEY CLUSTERED 
(
	[FileTypeId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Module_Application]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Module_Application](
	[ApplicationGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[ApplicationId] [int] IDENTITY(1000,1) NOT NULL,
	[ApplicationName] [nvarchar](50) NOT NULL,
	[ApplicationDescription] [ntext] NULL,
	[ApplicationOrder] [int] NOT NULL,
	[ApplicationVisible] [bit] NOT NULL,
 CONSTRAINT [PK_Module_Application] PRIMARY KEY CLUSTERED 
(
	[ApplicationGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Module_BarItem]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Module_BarItem](
	[BarItemGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[BarItemId] [int] IDENTITY(1000,1) NOT NULL,
	[ParentBarItemGuid] [uniqueidentifier] NOT NULL,
	[RibbonBarGuid] [uniqueidentifier] NOT NULL,
	[CommandGuid] [uniqueidentifier] NULL,
	[BarItemName] [nvarchar](128) NOT NULL,
	[BarItemImage] [nvarchar](1024) NULL,
	[BarItemImageSize] [int] NULL,
	[BarItemTypeId] [int] NOT NULL,
	[BarItemOrder] [int] NOT NULL,
 CONSTRAINT [PK_Module_BarItem] PRIMARY KEY CLUSTERED 
(
	[BarItemGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Module_Command]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Module_Command](
	[CommandGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[CommandId] [int] IDENTITY(100,1) NOT NULL,
	[FileGuid] [uniqueidentifier] NOT NULL,
	[CommandName] [nvarchar](1024) NOT NULL,
	[CommandCode] [nvarchar](1024) NOT NULL,
	[CommandDescription] [ntext] NULL,
	[CommandType] [nvarchar](2048) NOT NULL,
 CONSTRAINT [PK_Module_Command] PRIMARY KEY CLUSTERED 
(
	[CommandGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Module_File]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Module_File](
	[FileGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[FileId] [int] IDENTITY(1000,1) NOT NULL,
	[ApplicationGuid] [uniqueidentifier] NOT NULL,
	[FileName] [nvarchar](1024) NOT NULL,
	[FileDescription] [ntext] NULL,
	[FileUrl] [nvarchar](2048) NOT NULL,
	[FilePath] [nvarchar](1024) NULL,
	[FileVersionMajor] [int] NOT NULL,
	[FileVersionMinor] [int] NOT NULL,
	[FileVersionBuild] [int] NOT NULL,
	[FileVersionRevision] [int] NOT NULL,
	[FileTypeId] [int] NOT NULL,
	[FileOrder] [int] NOT NULL,
 CONSTRAINT [PK_Module_File] PRIMARY KEY CLUSTERED 
(
	[FileGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Module_Ribbon]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Module_Ribbon](
	[RibbonGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[RibbonId] [int] IDENTITY(1000,1) NOT NULL,
	[ApplicationGuid] [uniqueidentifier] NOT NULL,
	[RibbonName] [nvarchar](50) NOT NULL,
	[RibbonOrder] [int] NOT NULL,
 CONSTRAINT [PK_Module_Ribbon] PRIMARY KEY CLUSTERED 
(
	[RibbonGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Module_RibbonBar]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Module_RibbonBar](
	[RibbonBarGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[RibbonBarId] [int] IDENTITY(1000,1) NOT NULL,
	[RibbonGuid] [uniqueidentifier] NOT NULL,
	[RibbonBarName] [nvarchar](50) NOT NULL,
	[RibbonBarOrder] [int] NOT NULL,
 CONSTRAINT [PK_Module_RibbonBar] PRIMARY KEY CLUSTERED 
(
	[RibbonBarGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Security_ApplicationRole]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Security_ApplicationRole](
	[ApplicationGuid] [uniqueidentifier] NOT NULL,
	[RoleGuid] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Security_ApplicationRole] PRIMARY KEY CLUSTERED 
(
	[ApplicationGuid] ASC,
	[RoleGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Security_CommandRole]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Security_CommandRole](
	[CommandGuid] [uniqueidentifier] NOT NULL,
	[RoleGuid] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Security_CommandRole] PRIMARY KEY CLUSTERED 
(
	[CommandGuid] ASC,
	[RoleGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Security_RibbonBarRole]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Security_RibbonBarRole](
	[RibbonBarGuid] [uniqueidentifier] NOT NULL,
	[RoleGuid] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Security_RibbonBarRole] PRIMARY KEY CLUSTERED 
(
	[RibbonBarGuid] ASC,
	[RoleGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Security_RibbonRole]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Security_RibbonRole](
	[RibbonGuid] [uniqueidentifier] NOT NULL,
	[RoleGuid] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Security_RibbonRole] PRIMARY KEY CLUSTERED 
(
	[RibbonGuid] ASC,
	[RoleGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Security_Role]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Security_Role](
	[RoleGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[RoleId] [int] IDENTITY(1000,1) NOT NULL,
	[RoleName] [nvarchar](30) NOT NULL,
	[RoleDescription] [ntext] NULL,
 CONSTRAINT [PK_Security_Role] PRIMARY KEY CLUSTERED 
(
	[RoleGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Security_Session]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Security_Session](
	[SessionGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[UserGuid] [uniqueidentifier] NOT NULL,
	[ApplicationGuid] [uniqueidentifier] NOT NULL,
	[ProcessDateTime] [datetime] NOT NULL,
 CONSTRAINT [PK_Security_Session] PRIMARY KEY CLUSTERED 
(
	[SessionGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Security_SessionActivity]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Security_SessionActivity](
	[SessionActivityGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[SessionGuid] [uniqueidentifier] NOT NULL,
	[ProcessDateTime] [datetime] NOT NULL,
 CONSTRAINT [PK_Security_SessionActivity] PRIMARY KEY CLUSTERED 
(
	[SessionActivityGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Security_Transaction]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Security_Transaction](
	[TransactionGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[SessionGuid] [uniqueidentifier] NOT NULL,
	[TransactionTypeGuid] [uniqueidentifier] NOT NULL,
	[Completed] [bit] NOT NULL,
	[CompletedDateTime] [datetime] NULL,
	[ProcessDateTime] [datetime] NOT NULL,
 CONSTRAINT [PK_Security_Transaction] PRIMARY KEY CLUSTERED 
(
	[TransactionGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Security_User]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Security_User](
	[UserGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[UserId] [int] IDENTITY(10000,1) NOT NULL,
	[Username] [nvarchar](50) NOT NULL,
	[Password] [nvarchar](255) NOT NULL,
	[email] [nvarchar](128) NOT NULL,
	[Active] [bit] NOT NULL,
	[StartupScript] [nvarchar](255) NULL,
 CONSTRAINT [PK_Security_User] PRIMARY KEY CLUSTERED 
(
	[UserGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Security_UserRole]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Security_UserRole](
	[UserGuid] [uniqueidentifier] NOT NULL,
	[RoleGuid] [uniqueidentifier] NOT NULL,
 CONSTRAINT [PK_Security_UserRole] PRIMARY KEY CLUSTERED 
(
	[UserGuid] ASC,
	[RoleGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Transaction_Category]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Transaction_Category](
	[TransactionCategoryGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[TransactionCategoryId] [int] IDENTITY(1,1) NOT NULL,
	[ParentTransactionCategoryGuid] [uniqueidentifier] NOT NULL,
	[TransactionCategoryName] [nvarchar](50) NOT NULL,
	[TransactionCategoryDescription] [ntext] NULL,
 CONSTRAINT [PK_Transaction_Category] PRIMARY KEY CLUSTERED 
(
	[TransactionCategoryGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

USE [Genesis]
GO

/****** Object:  Table [dbo].[Transaction_TransactionType]    Script Date: 07/21/2009 21:55:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Transaction_TransactionType](
	[TransactionTypeGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
	[TransactionTypeId] [int] IDENTITY(1,1) NOT NULL,
	[TransactionCategoryGuid] [uniqueidentifier] NOT NULL,
	[TransactionTypeName] [nvarchar](30) NOT NULL,
	[TransactionTypeCode] [nvarchar](128) NOT NULL,
	[TransactionTypeDescription] [ntext] NULL,
 CONSTRAINT [PK_Transaction_TransactionType] PRIMARY KEY NONCLUSTERED 
(
	[TransactionTypeGuid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_Transaction_TransactionCode] UNIQUE CLUSTERED 
(
	[TransactionTypeCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

ALTER TABLE [dbo].[Exception_LogEntry] ADD  CONSTRAINT [DF_Exception_LogEntry_LogEntryGuid]  DEFAULT (newid()) FOR [LogEntryGuid]
GO

ALTER TABLE [dbo].[Exception_LogEntry] ADD  CONSTRAINT [DF_Exception_LogEntry_LogEntryTypeId]  DEFAULT ((0)) FOR [LogEntryTypeId]
GO

ALTER TABLE [dbo].[Exception_LogEntry] ADD  CONSTRAINT [DF_Exception_LogEntry_ProcessDateTime]  DEFAULT (getdate()) FOR [ProcessDateTime]
GO

ALTER TABLE [dbo].[Module_Application] ADD  CONSTRAINT [DF_Module_Application_ApplicationGuid]  DEFAULT (newid()) FOR [ApplicationGuid]
GO

ALTER TABLE [dbo].[Module_Application] ADD  CONSTRAINT [DF_Module_Application_ApplicationOrder]  DEFAULT ((10000)) FOR [ApplicationOrder]
GO

ALTER TABLE [dbo].[Module_Application] ADD  CONSTRAINT [DF_Module_Application_ApplicationVisible]  DEFAULT ((0)) FOR [ApplicationVisible]
GO

ALTER TABLE [dbo].[Module_BarItem]  WITH CHECK ADD  CONSTRAINT [FK_Module_BarItem_Lookup_BarItemType] FOREIGN KEY([BarItemTypeId])
REFERENCES [dbo].[Lookup_BarItemType] ([BarItemTypeId])
GO

ALTER TABLE [dbo].[Module_BarItem] CHECK CONSTRAINT [FK_Module_BarItem_Lookup_BarItemType]
GO

ALTER TABLE [dbo].[Module_BarItem]  WITH NOCHECK ADD  CONSTRAINT [FK_Module_BarItem_Module_BarItem] FOREIGN KEY([ParentBarItemGuid])
REFERENCES [dbo].[Module_BarItem] ([BarItemGuid])
NOT FOR REPLICATION 
GO

ALTER TABLE [dbo].[Module_BarItem] NOCHECK CONSTRAINT [FK_Module_BarItem_Module_BarItem]
GO

ALTER TABLE [dbo].[Module_BarItem]  WITH CHECK ADD  CONSTRAINT [FK_Module_BarItem_Module_Command] FOREIGN KEY([CommandGuid])
REFERENCES [dbo].[Module_Command] ([CommandGuid])
GO

ALTER TABLE [dbo].[Module_BarItem] CHECK CONSTRAINT [FK_Module_BarItem_Module_Command]
GO

ALTER TABLE [dbo].[Module_BarItem]  WITH CHECK ADD  CONSTRAINT [FK_Module_BarItem_Module_RibbonBar] FOREIGN KEY([RibbonBarGuid])
REFERENCES [dbo].[Module_RibbonBar] ([RibbonBarGuid])
GO

ALTER TABLE [dbo].[Module_BarItem] CHECK CONSTRAINT [FK_Module_BarItem_Module_RibbonBar]
GO

ALTER TABLE [dbo].[Module_BarItem]  WITH CHECK ADD  CONSTRAINT [FK_Module_BarItem_Module_RibbonBar1] FOREIGN KEY([RibbonBarGuid])
REFERENCES [dbo].[Module_RibbonBar] ([RibbonBarGuid])
GO

ALTER TABLE [dbo].[Module_BarItem] CHECK CONSTRAINT [FK_Module_BarItem_Module_RibbonBar1]
GO

ALTER TABLE [dbo].[Module_BarItem] ADD  CONSTRAINT [DF_Module_BarItem_BarItemGuid]  DEFAULT (newid()) FOR [BarItemGuid]
GO

ALTER TABLE [dbo].[Module_BarItem] ADD  CONSTRAINT [DF_Module_BarItem_ParentBarItemGuid]  DEFAULT ('00000000-0000-0000-0000-000000000000') FOR [ParentBarItemGuid]
GO

ALTER TABLE [dbo].[Module_BarItem] ADD  CONSTRAINT [DF_Module_BarItem_BarItemTypeId]  DEFAULT ((0)) FOR [BarItemTypeId]
GO

ALTER TABLE [dbo].[Module_BarItem] ADD  CONSTRAINT [DF_Module_BarItem_BarItemOrder]  DEFAULT ((10000)) FOR [BarItemOrder]
GO

ALTER TABLE [dbo].[Module_Command]  WITH CHECK ADD  CONSTRAINT [FK_Module_Command_Module_File] FOREIGN KEY([FileGuid])
REFERENCES [dbo].[Module_File] ([FileGuid])
GO

ALTER TABLE [dbo].[Module_Command] CHECK CONSTRAINT [FK_Module_Command_Module_File]
GO

ALTER TABLE [dbo].[Module_Command] ADD  CONSTRAINT [DF_Module_Command_CommandGuid]  DEFAULT (newid()) FOR [CommandGuid]
GO

ALTER TABLE [dbo].[Module_File]  WITH CHECK ADD  CONSTRAINT [FK_Module_File_Lookup_FileType] FOREIGN KEY([FileTypeId])
REFERENCES [dbo].[Lookup_FileType] ([FileTypeId])
GO

ALTER TABLE [dbo].[Module_File] CHECK CONSTRAINT [FK_Module_File_Lookup_FileType]
GO

ALTER TABLE [dbo].[Module_File]  WITH CHECK ADD  CONSTRAINT [FK_Module_File_Module_Application] FOREIGN KEY([ApplicationGuid])
REFERENCES [dbo].[Module_Application] ([ApplicationGuid])
GO

ALTER TABLE [dbo].[Module_File] CHECK CONSTRAINT [FK_Module_File_Module_Application]
GO

ALTER TABLE [dbo].[Module_File] ADD  CONSTRAINT [DF_Module_File_FileGuid]  DEFAULT (newid()) FOR [FileGuid]
GO

ALTER TABLE [dbo].[Module_File] ADD  CONSTRAINT [DF_Module_File_FileVersionMajor]  DEFAULT ((0)) FOR [FileVersionMajor]
GO

ALTER TABLE [dbo].[Module_File] ADD  CONSTRAINT [DF_Module_File_FileVersionMinor]  DEFAULT ((0)) FOR [FileVersionMinor]
GO

ALTER TABLE [dbo].[Module_File] ADD  CONSTRAINT [DF_Module_File_FileVersionBuild]  DEFAULT ((0)) FOR [FileVersionBuild]
GO

ALTER TABLE [dbo].[Module_File] ADD  CONSTRAINT [DF_Module_File_FileVersionRevision]  DEFAULT ((0)) FOR [FileVersionRevision]
GO

ALTER TABLE [dbo].[Module_File] ADD  CONSTRAINT [DF_Module_File_FileOrder]  DEFAULT ((10000)) FOR [FileOrder]
GO

ALTER TABLE [dbo].[Module_Ribbon]  WITH CHECK ADD  CONSTRAINT [FK_Module_Ribbon_Module_Application] FOREIGN KEY([ApplicationGuid])
REFERENCES [dbo].[Module_Application] ([ApplicationGuid])
GO

ALTER TABLE [dbo].[Module_Ribbon] CHECK CONSTRAINT [FK_Module_Ribbon_Module_Application]
GO

ALTER TABLE [dbo].[Module_Ribbon] ADD  CONSTRAINT [DF_Module_Ribbon_RibbonGuid]  DEFAULT (newid()) FOR [RibbonGuid]
GO

ALTER TABLE [dbo].[Module_Ribbon] ADD  CONSTRAINT [DF_Module_Ribbon_RibbonOrder]  DEFAULT ((10000)) FOR [RibbonOrder]
GO

ALTER TABLE [dbo].[Module_RibbonBar]  WITH CHECK ADD  CONSTRAINT [FK_Module_RibbonBar_Module_Ribbon] FOREIGN KEY([RibbonGuid])
REFERENCES [dbo].[Module_Ribbon] ([RibbonGuid])
GO

ALTER TABLE [dbo].[Module_RibbonBar] CHECK CONSTRAINT [FK_Module_RibbonBar_Module_Ribbon]
GO

ALTER TABLE [dbo].[Module_RibbonBar] ADD  CONSTRAINT [DF_Module_RibbonBar_RibbonBarGuid]  DEFAULT (newid()) FOR [RibbonBarGuid]
GO

ALTER TABLE [dbo].[Module_RibbonBar] ADD  CONSTRAINT [DF_Module_RibbonBar_RibbonBarOrder]  DEFAULT ((10000)) FOR [RibbonBarOrder]
GO

ALTER TABLE [dbo].[Security_ApplicationRole]  WITH CHECK ADD  CONSTRAINT [FK_Security_ApplicationRole_Module_Application] FOREIGN KEY([ApplicationGuid])
REFERENCES [dbo].[Module_Application] ([ApplicationGuid])
GO

ALTER TABLE [dbo].[Security_ApplicationRole] CHECK CONSTRAINT [FK_Security_ApplicationRole_Module_Application]
GO

ALTER TABLE [dbo].[Security_ApplicationRole]  WITH CHECK ADD  CONSTRAINT [FK_Security_ApplicationRole_Security_Role] FOREIGN KEY([RoleGuid])
REFERENCES [dbo].[Security_Role] ([RoleGuid])
GO

ALTER TABLE [dbo].[Security_ApplicationRole] CHECK CONSTRAINT [FK_Security_ApplicationRole_Security_Role]
GO

ALTER TABLE [dbo].[Security_CommandRole]  WITH CHECK ADD  CONSTRAINT [FK_Security_CommandRole_Module_Command] FOREIGN KEY([CommandGuid])
REFERENCES [dbo].[Module_Command] ([CommandGuid])
GO

ALTER TABLE [dbo].[Security_CommandRole] CHECK CONSTRAINT [FK_Security_CommandRole_Module_Command]
GO

ALTER TABLE [dbo].[Security_CommandRole]  WITH CHECK ADD  CONSTRAINT [FK_Security_CommandRole_Security_Role] FOREIGN KEY([RoleGuid])
REFERENCES [dbo].[Security_Role] ([RoleGuid])
GO

ALTER TABLE [dbo].[Security_CommandRole] CHECK CONSTRAINT [FK_Security_CommandRole_Security_Role]
GO

ALTER TABLE [dbo].[Security_RibbonBarRole]  WITH CHECK ADD  CONSTRAINT [FK_Security_RibbonBarRole_Module_RibbonBar] FOREIGN KEY([RibbonBarGuid])
REFERENCES [dbo].[Module_RibbonBar] ([RibbonBarGuid])
GO

ALTER TABLE [dbo].[Security_RibbonBarRole] CHECK CONSTRAINT [FK_Security_RibbonBarRole_Module_RibbonBar]
GO

ALTER TABLE [dbo].[Security_RibbonBarRole]  WITH CHECK ADD  CONSTRAINT [FK_Security_RibbonBarRole_Security_Role] FOREIGN KEY([RoleGuid])
REFERENCES [dbo].[Security_Role] ([RoleGuid])
GO

ALTER TABLE [dbo].[Security_RibbonBarRole] CHECK CONSTRAINT [FK_Security_RibbonBarRole_Security_Role]
GO

ALTER TABLE [dbo].[Security_RibbonRole]  WITH CHECK ADD  CONSTRAINT [FK_Security_RibbonRole_Module_Ribbon] FOREIGN KEY([RibbonGuid])
REFERENCES [dbo].[Module_Ribbon] ([RibbonGuid])
GO

ALTER TABLE [dbo].[Security_RibbonRole] CHECK CONSTRAINT [FK_Security_RibbonRole_Module_Ribbon]
GO

ALTER TABLE [dbo].[Security_RibbonRole]  WITH CHECK ADD  CONSTRAINT [FK_Security_RibbonRole_Security_Role] FOREIGN KEY([RoleGuid])
REFERENCES [dbo].[Security_Role] ([RoleGuid])
GO

ALTER TABLE [dbo].[Security_RibbonRole] CHECK CONSTRAINT [FK_Security_RibbonRole_Security_Role]
GO

ALTER TABLE [dbo].[Security_Role] ADD  CONSTRAINT [DF_Security_Role_RoleGuid]  DEFAULT (newid()) FOR [RoleGuid]
GO

ALTER TABLE [dbo].[Security_Session]  WITH CHECK ADD  CONSTRAINT [FK_Security_Session_Security_User] FOREIGN KEY([UserGuid])
REFERENCES [dbo].[Security_User] ([UserGuid])
GO

ALTER TABLE [dbo].[Security_Session] CHECK CONSTRAINT [FK_Security_Session_Security_User]
GO

ALTER TABLE [dbo].[Security_Session] ADD  CONSTRAINT [DF_Security_Session_SessionGuid]  DEFAULT (newid()) FOR [SessionGuid]
GO

ALTER TABLE [dbo].[Security_Session] ADD  CONSTRAINT [DF_Security_Session_ProcessDateTime]  DEFAULT (getdate()) FOR [ProcessDateTime]
GO

ALTER TABLE [dbo].[Security_SessionActivity]  WITH CHECK ADD  CONSTRAINT [FK_Security_SessionActivity_Security_Session] FOREIGN KEY([SessionGuid])
REFERENCES [dbo].[Security_Session] ([SessionGuid])
GO

ALTER TABLE [dbo].[Security_SessionActivity] CHECK CONSTRAINT [FK_Security_SessionActivity_Security_Session]
GO

ALTER TABLE [dbo].[Security_SessionActivity] ADD  CONSTRAINT [DF_Security_SessionActivity_SessionActivityGuid]  DEFAULT (newid()) FOR [SessionActivityGuid]
GO

ALTER TABLE [dbo].[Security_SessionActivity] ADD  CONSTRAINT [DF_Security_SessionActivity_ProcessDateTime]  DEFAULT (getdate()) FOR [ProcessDateTime]
GO

ALTER TABLE [dbo].[Security_Transaction] ADD  CONSTRAINT [DF_Security_Transaction_TransactionGuid]  DEFAULT (newid()) FOR [TransactionGuid]
GO

ALTER TABLE [dbo].[Security_Transaction] ADD  CONSTRAINT [DF_Security_Transaction_Completed]  DEFAULT ((0)) FOR [Completed]
GO

ALTER TABLE [dbo].[Security_Transaction] ADD  CONSTRAINT [DF_Security_Transaction_ProcessDateTime]  DEFAULT (getdate()) FOR [ProcessDateTime]
GO

ALTER TABLE [dbo].[Security_User] ADD  CONSTRAINT [DF_Security_User_UserGuid]  DEFAULT (newid()) FOR [UserGuid]
GO

ALTER TABLE [dbo].[Security_User] ADD  CONSTRAINT [DF_Security_User_Active]  DEFAULT ((0)) FOR [Active]
GO

ALTER TABLE [dbo].[Security_UserRole]  WITH CHECK ADD  CONSTRAINT [FK_Security_UserRole_Security_Role] FOREIGN KEY([RoleGuid])
REFERENCES [dbo].[Security_Role] ([RoleGuid])
GO

ALTER TABLE [dbo].[Security_UserRole] CHECK CONSTRAINT [FK_Security_UserRole_Security_Role]
GO

ALTER TABLE [dbo].[Security_UserRole]  WITH CHECK ADD  CONSTRAINT [FK_Security_UserRole_Security_User] FOREIGN KEY([UserGuid])
REFERENCES [dbo].[Security_User] ([UserGuid])
GO

ALTER TABLE [dbo].[Security_UserRole] CHECK CONSTRAINT [FK_Security_UserRole_Security_User]
GO

ALTER TABLE [dbo].[Transaction_Category] ADD  CONSTRAINT [DF_Transaction_Category_TransactionCategoryGuid]  DEFAULT (newid()) FOR [TransactionCategoryGuid]
GO

ALTER TABLE [dbo].[Transaction_Category] ADD  CONSTRAINT [DF_Transaction_Category_ParentTransactionCategoryGuid]  DEFAULT ('{00000000-0000-0000-0000-000000000000}') FOR [ParentTransactionCategoryGuid]
GO

ALTER TABLE [dbo].[Transaction_TransactionType] ADD  CONSTRAINT [DF_Transaction_TransactionType_TransactionTypeGuid]  DEFAULT (newid()) FOR [TransactionTypeGuid]
GO

